
<!--
 作者 : 唐梓元
 日期 : 2019-7-8
 版本 : 1.0
 描述 :信息列表组件首页和收藏页面使用
 使用 : <query-collect :titleRefresh="titleRefresh"></query-collect>
 参数 :titleRefresh 为父组件传过来的值
 -->
<template>
  <div>
    <div class="listWrapper minWidth" v-for="(item,index) in getQueryData.Data">
      <div class="list-title flex" @click="do_goDetail(item.SN)"><img src="../../assets/commonImg/gankuang201974.png" alt=""><span class="flex1" v-text="item.title"></span></div>
      <ul class="list-info">
        <li><span>完成人员：</span> <span class="finishMan" v-for="(itemMan,indexMan) in item.FinishMan.split('，')" v-text="itemMan"></span></li>
        <li><span>所属单位：</span> <span v-text="item.WorkUnitName"></span></li>
        <li><span>课题来源：</span> <span v-text="item.EvaluationOrigin"></span></li>
        <li><span>成果范围：</span> <span v-text="item.TopticType"></span></li>
      </ul>
      <!--<collectRatStar :needCompare="needCompare"></collectRatStar>-->
      <div class="list-bottom flex">
        <ul class=" flex flex1">
          <li class="flex150"><img src="../../assets/commonImg/dianji201974.png" alt=""><span v-text="item.ViewCount">32</span></li>
          <li class="flex150"><img src="../../assets/commonImg/shoucang.png" alt=""><span v-text="item.CollectNumber">32</span></li>
          <li class="flex200 flex"><img src="../../assets/commonImg/pinglun.png" alt=""><star :score="item.EvaluatValue.toString()"></star></li>
        </ul>
        <div class="flex text-right pointer ">
          <div class="check pointer" v-if="needCompare"><label @click="do_select(item)" ><input   type="checkbox"  :class="item.IsCom?'inputCheck':''"> <span class="pointer" v-text="item.IsCom?'已加入对比':'加入对比'"></span></label> </div>
          <div @click="do_collect(item)"><span>{{item.isCollect?'取消收藏':'收藏'}}</span><span class="collectImg1" :class="item.isCollect?'collectImg2':'collectImg1'"></span></div></div>
      </div>
    </div>
  </div>

</template>

<script>
// import collectRatStar from './cm_query-collect-ratStar'
import star from '../common/cm_star'
    export default {
        name: "cm_query-collect",
      inject:['reload'],
      components:{
        star,
        // collectRatStar
      },
      props:{
        needCompare:{
          type:Boolean,
          default:false
        }
      },
      data(){
          return{
            collectText:'',
            checkBox: false,
            collectItem:{},
            compareItem:{},
            compareNumber:0
          }
      },
      methods:{
        do_select(item){
          let me =this
          me.compareItem=item
          me.$ZcPublic.zcServer.Post({      //退出接口调用
            IsNeedLogin:'true',
            Paras:{
              Name: 'Vue_resultLib',
              Action: 'doComple_ResultShow',
              Data:{
                SN:item.SN,
                isComple:!item.IsCom
              }
            },
            Callback:me.cb_Comple_ResultShow,
            Scope:me
          })
        },
        cb_Comple_ResultShow(resJson,scope){
          console.log('比较返回',resJson)
          if(resJson.success){
            this.compareItem.IsCom=!this.compareItem.IsCom
            this.$emit('do_compare')
          }else {
            if(resJson.msg.indexOf('登录')>=0){
              this.$confirm({
                type:'温馨提示',
                msg:resJson.msg,
                btn:{
                  ok:'ok',
                  no:'no'
                }
              })
                .then(()=>{
                  localStorage.setItem("JumpKey", window.location.href);
                  this.$router.push('/BS_cgkLogin')
                })
            }else {
              this.$confirm({
                type:'温馨提示',
                msg:resJson.msg,
                btn:{
                  ok:'ok'

                }
              })
            }

          }
        },
        do_goDetail(SN){

          // this.$router.push("yw_subjectDetail")
          this.$router.push({name:"yw_subjectDetail",query:{SN:SN}})
        },
        do_collect(item){
          this.collectItem=item
          if(!item.isCollect){
            this.collectText="收藏成功！"
          }else {
            this.collectText="取消收藏成功！"
          }
          let me =this
          me.$ZcPublic.zcServer.Post({      //退出接口调用
            IsNeedLogin:'true',
            Paras:{
              Name: 'Vue_resultLib',
              Action: 'doCollect_ResultShow',
              Data:{
                SN:item.SN,
                IsCollect:!item.isCollect
              }
            },
            Callback:me.cb_Collect_ResultShow,
            Scope:me
          })
        },
        cb_Collect_ResultShow(resJson,scope){
          console.log('收藏返回',resJson)
          if(resJson.success){
            this.$toast({
              icon:'ok',
              msg:this.collectText
            })
            let me=this
            setTimeout(()=>{
              me.collectItem.isCollect=!me.collectItem.isCollect
            },1600)
          }else {
           this.$confirm({
             type:"错误",
             msg:resJson.msg,
             btn:{
               ok:'yes',
               no:"no"
             }
           })
             .then(()=>{
               localStorage.setItem("JumpKey", window.location.href);
               this.$router.push('/BS_cgkLogin')
             })
          }
        }
      },
      computed: {
        getQueryData(){
          return this.$store.getters.getQueryData
        },
        // getCompareData(){
        //   return this.$store.getters.getCompareData
        // }
      },
    }
</script>

<style scoped>
  .listWrapper{
    background-color: white;
    padding: 15px 25px 5px;
    margin-top: 15px;
  }

  .list-title{
    font-size: 18px;
    font-weight: bold;
    padding: 5px 0 10px;
    align-items: center;
    cursor: pointer;
  }
  .list-title img{
    width: 20px;
    height: 20px;
    margin-right: 10px;
  }
  .list-info,.list-bottom{
    padding-left: 10px;
    color: grey;
    font-size: 14px;
    line-height: 25px;

  }
  .list-info{
    margin-bottom: 8px;
  }
  .finishMan{
    margin-right: 15px;
  }


  input[type="checkbox"]{
    /*margin-left: 10px;*/
    position: relative;
    width: 19px;
    height: 19px;
    background-color: transparent;
    -webkit-appearance: none;
    outline: none;
    border: 1px solid white;
    left: -3px !important;
  }
  input[type="checkbox"]:before{
    font-family: "iconfont" ;
    content: "\e673" ;
    font-size:24px ;
    font-weight: 400 !important;
    color: #408DFE !important;
    cursor: pointer !important;
    display: inline-block !important;
    margin: -2px 0px 0px -10px !important;
    z-index: 99 !important;
    position: absolute !important;
    left: 4px !important;
    top: 3px !important;
  }
  .inputCheck:before{
    font-family: "iconfont" ;
    content: "\e66e" !important;
    font-size:20px !important;
    font-weight: 400 !important;
    color: #408DFE !important;
    cursor: pointer !important;
    display: inline-block !important;
    margin: -2px 0px 0px -10px !important;
    z-index: 99 !important;
    position: absolute !important;
    left: 4px !important;
    top: 3px !important;
  }
  .check{
    margin-right: 60px;
  }
  .list-info,.list-bottom{
    padding-left: 10px;
    color: grey;
    font-size: 14px;
    line-height: 25px;

  }

  .flex150{
    flex: 0 0 150px;
  }
  .flex200{
    flex: 0 0 200px;
  }
  .list-bottom{
    height: 30px;
    align-items: center;
    margin-top: 0;
  }
  .list-bottom>ul,.list-bottom>div{
    height: 30px;
    margin-bottom: 0;
  }
  .list-bottom ul li img{
    width: 16px;
    height: 14px;
    position: relative;
    top: -3px;
    margin-right: 5px;
  }
  .list-bottom li{
    align-items: center;
    height: 30px;
    line-height: 30px;
  }
  .collectImg1,.collectImg2{
    width: 16px;
    height: 16px;
    display: inline-block;
    background:url("../../assets/commonImg/shoucang_weixuanzhong201974.png") center center no-repeat ;
    background-size: 14px 14px;
    margin-left: 5px;
    position: relative;
    top: 2px;
  }
  .collectImg2{
    background:url("../../assets/commonImg/shoucang_xuanzhong201974.png") center center no-repeat ;
    background-size: 14px 14px;
  }
</style>
